from django.test import TestCase
from utils.IOService import get_product
from django.core.management import call_command

class ProductDataFrameTest(TestCase):
    def setUp(self):
        pass

    def test_get_product_dataframe(self):
        """测试从数据库读取商品数据到DataFrame"""
        df = get_product()
        
        # 验证DataFrame不为空
        self.assertFalse(df.empty)
        
        # 验证必要的列是否存在
        expected_columns = ['product_code', 'product_name', 'default_retail_price', 'status']
        for col in expected_columns:
            self.assertIn(col, df.columns)
        
        # 验证数据类型
        self.assertEqual(df['default_retail_price'].dtype.kind, 'f')  # 验证价格是浮点数
